home *** CD-ROM | disk | FTP | other *** search
- package com.ibm.xml.dom;
-
- import java.io.IOException;
- import java.io.ObjectOutputStream;
- import java.io.Serializable;
- import org.w3c.dom.DOMException;
- import org.w3c.dom.Document;
- import org.w3c.dom.EntityReference;
- import org.w3c.dom.NamedNodeMap;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
-
- public abstract class NodeImpl implements Node, NodeList, Cloneable, Serializable {
- static final long serialVersionUID = 2815829867052120872L;
- public static final short ELEMENT_DEFINITION_NODE = -1;
- protected DocumentImpl ownerDocument;
- protected NodeImpl parentNode;
- protected NodeImpl previousSibling;
- protected NodeImpl nextSibling;
- protected String name;
- protected String value;
- protected boolean readOnly;
- protected Object userData;
- protected NodeImpl firstChild;
- protected NodeImpl lastChild;
- protected transient boolean syncChildren;
- protected transient boolean syncData;
- int changes;
- protected static int[] kidOK = new int[13];
-
- protected NodeImpl(DocumentImpl var1, String var2, String var3) {
- this.ownerDocument = var1 != null ? var1 : (DocumentImpl)this;
- this.name = var2;
- this.value = var3;
- }
-
- public NodeImpl() {
- }
-
- public abstract short getNodeType();
-
- public String getNodeName() {
- if (this.syncData) {
- this.synchronizeData();
- }
-
- return this.name;
- }
-
- public void setNodeValue(String var1) {
- if (this.readOnly) {
- throw new DOMExceptionImpl((short)7, (String)null);
- } else {
- if (this.syncData) {
- this.synchronizeData();
- }
-
- this.value = var1;
- }
- }
-
- public String getNodeValue() {
- if (this.syncData) {
- this.synchronizeData();
- }
-
- return this.value;
- }
-
- public Node appendChild(Node var1) throws DOMException {
- return this.insertBefore(var1, (Node)null);
- }
-
- public Node cloneNode(boolean var1) {
- if (this.syncData) {
- this.synchronizeData();
- }
-
- if (this.syncChildren) {
- this.synchronizeChildren();
- }
-
- NodeImpl var2;
- try {
- var2 = (NodeImpl)this.clone();
- } catch (CloneNotSupportedException var4) {
- return null;
- }
-
- var2.readOnly = false;
- var2.parentNode = null;
- var2.previousSibling = null;
- var2.nextSibling = null;
- var2.firstChild = null;
- var2.lastChild = null;
- if (var1) {
- for(NodeImpl var3 = (NodeImpl)this.getFirstChild(); var3 != null; var3 = (NodeImpl)var3.getNextSibling()) {
- var2.appendChild(var3.cloneNode(true));
- }
- }
-
- return var2;
- }
-
- public Document getOwnerDocument() {
- return this.ownerDocument;
- }
-
- public Node getParentNode() {
- return this.parentNode;
- }
-
- public Node getNextSibling() {
- return this.nextSibling;
- }
-
- public Node getPreviousSibling() {
- return this.previousSibling;
- }
-
- public NamedNodeMap getAttributes() {
- return null;
- }
-
- public boolean hasChildNodes() {
- if (this.syncChildren) {
- this.synchronizeChildren();
- }
-
- return this.firstChild != null;
- }
-
- public NodeList getChildNodes() {
- if (this.syncChildren) {
- this.synchronizeChildren();
- }
-
- return this;
- }
-
- public Node getFirstChild() {
- if (this.syncChildren) {
- this.synchronizeChildren();
- }
-
- return this.firstChild;
- }
-
- public Node getLastChild() {
- if (this.syncChildren) {
- this.synchronizeChildren();
- }
-
- return this.lastChild;
- }
-
- public Node insertBefore(Node var1, Node var2) throws DOMException {
- if (this.readOnly) {
- throw new DOMExceptionImpl((short)7, (String)null);
- } else if (var1 instanceof NodeImpl && (var1.getOwnerDocument() == this.ownerDocument || this.getNodeType() == 9 && var1.getOwnerDocument() == (Document)this)) {
- if (this.syncChildren) {
- this.synchronizeChildren();
- }
-
- NodeImpl var3 = (NodeImpl)var1;
- boolean var4 = true;
-
- for(NodeImpl var5 = this.parentNode; var4 && var5 != null; var5 = var5.parentNode) {
- var4 = var3 != var5;
- }
-
- if (!var4) {
- throw new DOMExceptionImpl((short)3, (String)null);
- } else if (var2 != null && var2.getParentNode() != this) {
- throw new DOMExceptionImpl((short)8, (String)null);
- } else {
- if (var3.getNodeType() == 11) {
- for(Node var6 = var3.getFirstChild(); var6 != null; var6 = var6.getNextSibling()) {
- if ((kidOK[this.getNodeType()] & 1 << var6.getNodeType()) == 0 && true) {
- throw new DOMExceptionImpl((short)3, (String)null);
- }
- }
-
- while(var3.hasChildNodes()) {
- this.insertBefore(var3.getFirstChild(), var2);
- }
- } else {
- if ((kidOK[this.getNodeType()] & 1 << var3.getNodeType()) == 0 && true) {
- throw new DOMExceptionImpl((short)3, (String)null);
- }
-
- Node var8 = var3.getParentNode();
- if (var8 != null) {
- var8.removeChild(var3);
- }
-
- NodeImpl var7 = var2 == null ? this.lastChild : ((NodeImpl)var2).previousSibling;
- var3.parentNode = this;
- var3.previousSibling = var7;
- if (var7 == null) {
- this.firstChild = var3;
- } else {
- var7.nextSibling = var3;
- }
-
- var3.nextSibling = (NodeImpl)var2;
- if (var2 == null) {
- this.lastChild = var3;
- } else {
- ((NodeImpl)var2).previousSibling = var3;
- }
- }
-
- this.changed();
- return var3;
- }
- } else {
- throw new DOMExceptionImpl((short)4, (String)null);
- }
- }
-
- public Node removeChild(Node var1) throws DOMException {
- if (this.readOnly) {
- throw new DOMExceptionImpl((short)7, (String)null);
- } else if (var1 != null && var1.getParentNode() != this) {
- throw new DOMExceptionImpl((short)8, (String)null);
- } else {
- NodeImpl var2 = (NodeImpl)var1;
- NodeImpl var3 = var2.previousSibling;
- NodeImpl var4 = var2.nextSibling;
- if (var3 != null) {
- var3.nextSibling = var4;
- } else {
- this.firstChild = var4;
- }
-
- if (var4 != null) {
- var4.previousSibling = var3;
- } else {
- this.lastChild = var3;
- }
-
- var2.parentNode = null;
- var2.nextSibling = null;
- var2.previousSibling = null;
- this.changed();
- return var2;
- }
- }
-
- public Node replaceChild(Node var1, Node var2) throws DOMException {
- this.insertBefore(var1, var2);
- return this.removeChild(var2);
- }
-
- public int getLength() {
- int var1 = 0;
-
- for(NodeImpl var2 = this.firstChild; var2 != null; var2 = var2.nextSibling) {
- ++var1;
- }
-
- return var1;
- }
-
- public Node item(int var1) {
- NodeImpl var2 = this.firstChild;
-
- for(int var3 = 0; var3 < var1 && var2 != null; ++var3) {
- var2 = var2.nextSibling;
- }
-
- return var2;
- }
-
- public void setReadOnly(boolean var1, boolean var2) {
- if (this.syncData) {
- this.synchronizeData();
- }
-
- this.readOnly = var1;
- if (var2) {
- if (this.syncChildren) {
- this.synchronizeChildren();
- }
-
- for(NodeImpl var3 = this.firstChild; var3 != null; var3 = var3.nextSibling) {
- if (!(var3 instanceof EntityReference)) {
- var3.setReadOnly(var1, true);
- }
- }
- }
-
- }
-
- public boolean getReadOnly() {
- if (this.syncData) {
- this.synchronizeData();
- }
-
- return this.readOnly;
- }
-
- public void setUserData(Object var1) {
- this.userData = var1;
- }
-
- public Object getUserData() {
- return this.userData;
- }
-
- protected void synchronizeChildren() {
- }
-
- protected void synchronizeData() {
- }
-
- protected void changed() {
- ++this.changes;
- if (this.parentNode != null) {
- this.parentNode.changed();
- }
-
- }
-
- protected static boolean isKidOK(Node var0, Node var1) {
- return (kidOK[var0.getNodeType()] & 1 << var1.getNodeType()) != 0;
- }
-
- public String toString() {
- return "[" + this.getNodeName() + ": " + this.getNodeValue() + "]";
- }
-
- private void writeObject(ObjectOutputStream var1) throws IOException {
- if (this.syncData) {
- this.synchronizeData();
- }
-
- if (this.syncChildren) {
- this.synchronizeChildren();
- }
-
- var1.defaultWriteObject();
- }
-
- static {
- kidOK[9] = 1410;
- kidOK[11] = kidOK[6] = kidOK[5] = kidOK[1] = 442;
- kidOK[2] = 40;
- kidOK[10] = kidOK[7] = kidOK[8] = kidOK[3] = kidOK[4] = kidOK[12] = 0;
- }
- }
-